package com.ruoyi.modules.service.impl;

import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.core.domain.entity.PayOrder;
import com.ruoyi.modules.mapper.PayOrderMapper;
import com.ruoyi.modules.service.PayOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单支付 业务层处理
 *
 * @author tlgen
 */
@Service
public class PayOrderServiceImpl implements PayOrderService
{
    @Autowired
    private PayOrderMapper payOrderMapper;

    /**
     * 根据条件分页查询订单支付数据
     */
    @Override
    public List<PayOrder> selectPayOrderList(PayOrder payOrder)
    {
        return payOrderMapper.selectPayOrderList(payOrder);
    }


    /**
     * 根据订单支付数据ID查询信息
     */
    @Override
    public PayOrder selectPayOrderById(Long payOrderId)
    {
        return payOrderMapper.selectPayOrderById(payOrderId);
    }

    @Override
    public PayOrder selectPayOrderByOrderNo(String orderNo) {
        return payOrderMapper.selectPayOrderByOrderNo(orderNo);
    }

    /**
     * 根据userId和最新时间查询最新支付订单记录
     * @param userId
     * @return
     */
    @Override
    public PayOrder selectNewOneByUserIdAndNewAddTime(Long userId) {
        return payOrderMapper.selectNewOneByUserIdAndNewAddTime(userId);
    }

    /**
     * 批量删除订单支付数据信息
     */
    @Override
    public int deletePayOrderByIds(Long[] payOrderIds)
    {
        int row = payOrderMapper.deletePayOrderByIds(payOrderIds);
        if (row > 0)
        {
            DictUtils.clearDictCache();
        }
        return row;
    }

    /**
     * 新增保存订单支付数据信息
     */
    @Override
    public int insertPayOrder(PayOrder payOrder)
    {
        int row = payOrderMapper.insertPayOrder(payOrder);
        if (row > 0)
        {
            DictUtils.clearDictCache();
        }
        return row;
    }

    /**
     * 修改保存订单支付数据信息
     */
    @Override
    public int updatePayOrder(PayOrder payOrder)
    {
        int row = payOrderMapper.updatePayOrder(payOrder);
        if (row > 0)
        {
            DictUtils.clearDictCache();
        }
        return row;
    }

    /**
     * 根据贷款申请表ID查询支付表信息
     * @param payId 申请表ID
     * @return
     */
    @Override
    public PayOrder selectPayOrderListByPayId(Long payId) {
        return payOrderMapper.selectPayOrderByPayId(payId);
    }

    @Override
    public List<PayOrder> selectPayOrderListBySysUser(String userName) {
        return payOrderMapper.selectPayOrderListBySysUser(userName);
    }


}
